<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>采购计划表</title>
<script type="text/javascript" src="js/jquery-1.8.3.js"></script>
<script type="text/javascript" src="js/laypage.js"></script>
<script type="text/javascript">
	$(function(){
 		pageChange(1);
		//---------------------------分页函数------------start--------------------------
		function pageChange(curr) {
			$.get("cgjh/allCgjh", {"pageNumber": curr}, function(data) {
				trList(data); //调用下面trList()方法，填充表格数据
 				trPost(data[0].users);
				laypage({ 
				    cont: $('#pages'), //容器。值支持id名、原生dom对象，jquery对象,
				    pages: data[0].users.totalPage, //总页数
				    skip: true, //是否开启跳页
				    skin: 'molv',//设置信息流模式样式
				    last:  data[0].users.totalPage, //总页数，将尾页显示为总页数
				    curr: data[0].users.pageNumber,//当前页
				    groups: 3, //连续显示分页数
				    jump: function(obj, first) {
					if(!first){ //一定要加此判断，否则初始时会无限刷新
						pageChange(obj.curr);
					}
				    }
				}); 
			});
		}
		//---------------------------分页函数------end----------------------------------
		//----------------------------表格填充-----start----------------------------------
		/* 填充表格 */
		    function trList(data) {
			var dataStr = "";
	        $.each(data.list, function(i, c) {//遍历cgjh结果集
	            dataStr += '<tr role="row" class="even">';
	            dataStr += '<td>'+c.cgjhh+'</td>';
	            dataStr += '<td>'+c.xqdh+'</td>';
	            dataStr += '<td>'+c.xqr+'</td>';
	            dataStr += '<td>'+c.xqxdsj+'</td>';
	            dataStr += '<td>'+c.xqwcsj+'</td>';
	            dataStr += '<td>'+c.cgkssj+'</td>';
	            dataStr += '<td>'+c.cgjssj+'</td>';
	            dataStr += '<td>'+c.cgqrrq+'</td>';
	            dataStr += '<td>'+c.cgqr+'</td>';
	            dataStr += '<td>'+c.gcdm+'</td>';
	            dataStr += '<td>'+c.bz+'</td>';
 	            dataStr += '<td><div class="hidden-sm hidden-xs action-buttons"><a href="';
	            dataStr +='javascript:allIngAjax(\''+c.xqdh;	            
	            dataStr +='\')" class="blue"> <i class="ace-icon fa fa-search-plus bigger-130"></i> </a> ';
 	    		//dataStr += '<a href="javascript:updateCgjh('+c.id+',\''+c.cgjhh+'\',\''+c.xqdh+'\',\''+c.xqr+'\',\''+c.xqxdsj+'\',\''+c.xqwcsj+'\',\''+c.cgkssj+'\','+c.cgjssj+',\''+c.cgqrrq+',\''+c.cgqr+'\',\''+c.gcdm'\',\''+c.bz+'\')"';
				//dataStr += ' class="green "><i class="ace-icon fa fa-pencil bigger-130"></i> </a> <a href="javascript:deleteC('+c.id+')" class="red"> <i class="ace-icon fa fa-trash-o bigger-130"></i> </a></div> </td></tr>';
 	    		dataStr += '<a href="javascript:updateCgjh('+c.id+","+c.cgjhh+","+c.xqdh+","+c.xqr+","+c.xqxdsj+","+c.xqwcsj+","+c.cgkssj+","+c.cgjssj+","+c.cgqrrq+","+c.cgqr+","+c.gcdm+","+c.bz+')"';
				dataStr += ' class="green "><i class="ace-icon fa fa-pencil bigger-130"></i> </a> <a href="javascript:deleteC('+c.id+')" class="red"> <i class="ace-icon fa fa-trash-o bigger-130"></i> </a></div> </td></tr>';
	        });
	
			// 把拼接好的表格内容填充到指定位置
			$("#tbody").html(dataStr);

		} 
		//----------------------------表格填充-----end----------------------------------
		//----------------------------分页菜单逻辑--start--------------------------------
		   function trPost(data){
			if(data.totalPage!=1){
				$("#laypage_3").addClass("hide");
				$("#get_pagination3").removeClass("hide");
				laypage({
				cont : $('#get_pagination3'), //容器。值支持id名、原生dom对象，jquery对象,
				pages : data.totalPage, //总页数
				skip : true, //是否开启跳页
				skin : '#2283C5',//保持ace中间的样式
				first: 1,
				last : data.totalPage, //总页数，将尾页显示为总页数
				curr : data.pageNumber,//当前页
				groups : 5, //连续显示分页数
				jump : function(obj, first) {
					if (!first) { //一定要加此判断，否则初始时会无限刷新
						pageChange(obj.curr);
					}
					}
				});
			}else{
				$("#get_pagination3").addClass("hide");
				$("#laypage_3").removeClass("hide");
			}						
		} 
		//----------------------------分页菜单逻辑--end-----------------------
		//----------------------------根据需求单号异步获取采购订单子表信息---start-----
	   	allIngAjax = function(xqdh){
	   		$.get("cgjh/findCgjha", {"xqdh": xqdh}, function(data) {
		    	allInf(data);		   
			}); 
		} 
		//----------------------------根据需求单号异步获取采购订单子表信息---end-------
		//---------------------------allInf查询采购计划子表信息----start---------
 		function allInf(data){
			$("#tbody").html("");
			var dataStr = "";
	        $.each(data, function(i, cgjha) {//遍历cgjha结果集
	            dataStr += '<tr role="row" class="even">';
	            dataStr += '<td>'+cgjha.cgjhh+'</td>';
	            dataStr += '<td>'+cgjha.xqdh+'</td>';
	            dataStr += '<td>'+cgjha.xqr+'</td>';
	            dataStr += '<td>'+cgjha.xqxdsj+'</td>';
	            dataStr += '<td>'+cgjha.xqwcsj+'</td>';
	            dataStr += '<td>'+cgjha.cgkssj+'</td>';
	            dataStr += '<td>'+cgjha.cgjssj+'</td>';
	            dataStr += '<td>'+cgjha.cgqrrq+'</td>';
	            dataStr += '<td>'+cgjha.cgqr+'</td>';
	            dataStr += '<td>'+cgjha.cpbm+'</td>';
	            dataStr += '<td>'+cgjha.wlbm+'</td>';
	            dataStr += '<td>'+cgjha.wlmc+'</td>';
	            dataStr += '<td>'+cgjha.ggxh+'</td>';
	            dataStr += '<td>'+cgjha.cglx+'</td>';
	            dataStr += '<td>'+cgjha.xqsl+'</td>';
	            dataStr += '<td>'+cgjha.yt+'</td>';
	            dataStr += '<td>'+cgjha.cgy+'</td>';
	            dataStr += '<td>'+cgjha.gcdm+'</td>';
	            dataStr += '<td>'+cgjha.bz+'</td>';
	            dataStr += '</tr>';
	        });
	
			// 把拼接好的表格内容填充到指定位置
			$("#tbody_a").html(dataStr);
			$('#sh').removeClass("hide");
			userModel = layer.open({
				type : 1,
				shade : [ 0.5 ],
				title : '采购计划详细信息', //不显示标题
				area : [ '100%', '80%' ], //显示空间
				content : $('#sh'), //捕获的元素
				btn : [  '关闭' ],
				cancel : function(index) {
					layer.close(index);
					$('#sh').addClass("hide"); //取消继续隐藏
				},
			});
		}  
		//---------------------------allInf---------end----------------
	});
</script>
</head>
<body>
<div class="breadcrumbs" id="breadcrumbs">
	<ul class="breadcrumb">
		<li><i class="ace-icon fa fa-home home-icon"></i> <a href="index">主页</a>
		</li>
		
		<li><span>控制台</span></li>
	</ul>
	<!-- /.breadcrumb -->
</div>
<div class="page-content">
	<div class="row">
		<div class="col-xs-12">
			<div class="clearfix"></div>
			<div class="table-header">用户管理</div>

			<!-- div.table-responsive -->

			<!-- div.dataTables_borderWrap -->
			<div>
				<div id="dynamic-table_wrapper"
					class="dataTables_wrapper form-inline no-footer">
					<form method="post" action="cgjh/allUser" id="main">
						<div class="row">
							<div class="col-xs-8">
								采购计划号<input type="text" placeholder="采购计划号" class="form-control" name="cgjh.cgjhh" />
								需求单号<input type="text" placeholder="需求单号" class="form-control" name="cgjh.xqdh" /> 
								需求人<input type="text" placeholder="需求人" class="form-control" name="cgjh.xqr" /><br/>
								需求下单时间<input type="text" placeholder="需求下单时间" class="form-control" name="cgjh.xqxdsj" onClick="WdatePicker()" readonly="readonly"/>
								需求完成时间<input type="text" placeholder="需求完成时间" class="form-control" name="cgjh.xqwcsj" onClick="WdatePicker()" readonly="readonly"/><br/>
								采购开始时间<input type="text" placeholder="采购开始时间" class="form-control" name="cgjh.cgkssj" onClick="WdatePicker()" readonly="readonly"/>
								采购结束时间<input type="text" placeholder="采购结束时间" class="form-control" name="cgjh.cgjssj" onClick="WdatePicker()" readonly="readonly"/><br/> 
								采购确认日期<input type="text" placeholder="采购确认日期" class="form-control" name="cgjh.cgqrrq" onClick="WdatePicker()" readonly="readonly"/>
								采购确认<select name="cgjh.cgqr">
										<option value="1">确认</option>
										<option value="2">未确认</option>
									</select><br/>
								工厂代码<input type="text" placeholder="工厂代码" class="form-control" name="cgjh.gcdm" />
								<a class="btn btn-sm btn-primary" id="submi">查询</a>
								<input type="reset" class="btn btn-sm btn-primary" onclick="javascript:chongZhi()" value="重置">
							</div>
						</div>
					</form>
						<div class="pull-right">
								<a class="btn btn-sm btn-primary"
									href="javascript:updateCgjh()">编辑</a>
								<a class="btn btn-sm btn-primary"
									href="javascript:cgjhInf()">查看</a>
								<a class="btn btn-sm btn-primary"
									href="javascript:deleteCgjh()">删除</a>
								<a class="btn btn-sm btn-primary"
									href="javascript:exportCgjh()">导出</a>
						</div>					
					<table
						class="table table-striped table-bordered table-hover">
						<thead>
								<tr>
								
									<th class="table_head"><span>采购计划号</span></th>
									<th class="table_head">需求单号</th>
									<th class="table_head"><span>需求人</span></th>
									<th class="table_head"><span>需求下单时间</span></th>
									<th class="table_head"><span>需求完成时间</span></th>
									<th class="table_head"><span>采购开始时间</span></th>
									<th class="table_head"><span>采购结束时间</span></th>
									<th class="table_head"><span>采购确认日期</span></th>
									<th class="table_head"><span>采购确认</span></th>
									<th class="table_head"><span>工厂代码</span></th>
									<th class="table_head"><span>备注</span></th>		
									<th width="80">操作</th>	
								</tr>
						</thead>
						<tbody id="tbody">

						</tbody>

					</table>

					<div class="row">
						<div class="col-xs-12">

							<div class="dataTables_paginate paging_simple_numbers  pull-left">
								<label>显示<select name="dynamic-table_length"
									aria-controls="dynamic-table" class="form-control input-sm"  id="sel">
									    <option value="10">10</option>
										<option value="20">20</option>
										<option value="50">50</option>
										<option value="100">100</option>
								</select> 条记录</label>
								</div>
								<div class="dataTables_paginate paging_simple_numbers">
										<ul class="pagination" id="get_pagination3">
										</ul>
										<div class="laypage_main laypageskin_molv" id="laypage_3">
											<span class="laypage_curr" style="background-color:#2283C5">1</span><span
												class="laypage_total"><label>到第</label><input max="1"
												min="1" class="laypage_skip" type="number"><label>页</label>
												<button type="button" class="laypage_btn">
													确定
													</button>
											</span>
										</div>
									</div>
						</div>
					</div>
				</div>
			</div>
</div>
<!-- 显示采购计划子表详细信息 -->
<div class="hide" id="sh">
	<div class="col-xs-2"></div>
	<div class="col-xs-8">
					<table
						class="table table-striped table-bordered table-hover">
						<thead>
							<tr height="30">
								<th>采购计划号</th>
								<th>需求单号</th>
								<th>需求人</th>
								<th>需求下单时间</th>
								<th>需求完成时间</th>
								<th>采购开始时间</th>
								<th>采购结束时间</th>
								<th>采购确认日期</th>
								<th>采购确认</th>
								<th>成品编码</th>
								<th>物料编码</th>
								<th>物料名称</th>
								<th>规格型号</th>
								<th>采购类型</th>
								<th>需求数量</th>
								<th>用途</th>
								<th>采购员</th>
								<th>工厂代码</th>
								<th>备注</th>
							</tr>
						</thead>
						<tbody id="tbody_a">

						</tbody>

					</table>
	</div>
	<div class="col-xs-2"></div>
</div>
</body>
</html>